package com.atos.howl.chaos.web.controller.user;

import com.atos.howl.chaos.enums.ChaosSysCodeEnum;
import com.atos.howl.chaos.pdm.dto.user.UserDTO;
import com.atos.howl.chaos.pdm.entity.User;
import com.atos.howl.chaos.pdm.service.UserService;
import com.atos.howl.chaos.utils.ChaosUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;


@Controller
@RequestMapping("/api/userController")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/getUserHeadImg")
    @ResponseBody
    public String getUserHeadImg(){
        //获取用户的头像
        String loginUserUUID = ChaosUtils.getLoginUserUUID();
        return userService.getUserHeadImgByUUID(loginUserUUID);
    }

//    @GetMapping("/getVideoPlayerLogo")
//    @ResponseBody
//    public String getVideoPlayerLogo(){
//        return userService.getVideoPlayerLogo();
//    }



    @GetMapping("/getUserInfo")
    @ResponseBody
    public UserDTO getUserInfo(){
        String uuid = ChaosUtils.getLoginUserUUID();
        return userService.getUserInfo(uuid);
    }

    @PostMapping("/updateUserInfo")
    @ResponseBody
    public ChaosSysCodeEnum updateUserInfo(@RequestBody User user){
        String uuid = ChaosUtils.getLoginUserUUID();
        user.setUserUuid(uuid);
        userService.updateUserInfo(user);
        return ChaosSysCodeEnum.SAVE_USERINFO_SUCCESS;
    }
}
